﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

using SsrsRenderStudio.Shared;
using SsrsRenderStudio.KnownTypesAndModels;

namespace SsrsRenderStudio.Wcf.DataContract
{
    #region User Service

    /// <summary>
    /// Information about the report execution.
    /// </summary>
    [DataContract]
    public class ExecutionResult
    {
        /// <summary>
        /// Was the execution successful.
        /// </summary>
        [DataMember]
        public bool IsSuccess;

        /// <summary>
        /// The ID of this execution, can be used for reprocessing.
        /// </summary>
        [DataMember]
        public Guid ExecutionId;

        /// <summary>
        /// When the report is removed from the cache.  Reprocessing can occur until this time.
        /// </summary>
        [DataMember]
        public DateTime ReportExpiration;

        /// <summary>
        /// Hard service error.
        /// </summary>
        [DataMember]
        public EnumServiceSideException ServiceSideException;

        /// <summary>
        /// Additional excepion info.
        /// </summary>
        [DataMember]
        public string ServiceSideExceptionAdditional;

        public ExecutionResult()
        {
            IsSuccess = false;
            ServiceSideException = EnumServiceSideException.NONE;
            ExecutionId = Guid.Empty;
            ReportExpiration = DateTime.MinValue;
            ServiceSideExceptionAdditional = string.Empty;
        }

        public ExecutionResult(bool success, EnumServiceSideException hardServiceException, string hardServiceExceptionAdditional, Guid id, DateTime expiration)
        {
            IsSuccess = success;
            ExecutionId = id;
            ServiceSideException = hardServiceException;
            ReportExpiration = expiration;
            ServiceSideExceptionAdditional = hardServiceExceptionAdditional;
        }
    }

    /// <summary>
    /// Lets the service know how to process the report.
    /// </summary>
    [DataContract]
    public class ExecutionContext
    {
        /// <summary>
        /// Report name.
        /// </summary>
        [DataMember]
        public string FriendlyReportName;

        /// <summary>
        /// Destination string.
        /// </summary>
        [DataMember]
        public string Destination;

        /// <summary>
        /// Parameters used to execute the report.
        /// </summary>
        [DataMember]
        public string[] ReportParameters;

        /// <summary>
        /// Optional: info about client.
        /// </summary>
        [DataMember]
        public string[] ClientInformation;

        public ExecutionContext(string friendlyReportName, string destination, string[] reportParameters, string[] clientInformation = null)
        {
            FriendlyReportName = friendlyReportName;
            Destination = destination;
            ReportParameters = reportParameters;
            ClientInformation = clientInformation;
            if (ClientInformation == null) ClientInformation = new string[] { "null" };
        }
    }

    #endregion 

    #region System Service

    [DataContract]
    public class ApplicationConfigResponse
    {
        [DataMember]
        public ApplicationConfig10 ApplicationConfig {get; set; }
    }

    [DataContract]
    public class SmtpConfigurationResponse
    {
        [DataMember]
        public SmtpConfig10 SmtpConfiguration { get; set; }
    }

    [DataContract]
    public class LoggingConfigurationsResponse
    {
        [DataMember]
        public List<LoggingConfig10> LoggingConfigurations { get; set; }
    }
    
    [DataContract]
    public class EndpointConfigurationsResponse
    {
        [DataMember]
        public List<EndpointConfig10> EndpointConfigurations { get; set; }
    }

    [DataContract]
    public class RenderStudioClientsResponse
    {
        [DataMember]
        public List<RenderStudioClientConfig10> RenderStudioClientConfigurations { get; set; }
    }

    [DataContract]
    public class RenderStudioServersResponse
    {
        [DataMember]
        public List<RenderStudioServerConfig10> RenderStudioServerConfigurations { get; set; }
    }

    [DataContract]
    public class ReportServersResponse
    {
        [DataMember]
        public List<ReportServerConfig10> ReportServerConfigurations { get; set; }
    }

    [DataContract]
    public class ReportsResponse
    {
        [DataMember]
        public List<ReportConfig10> ReportConfigurations { get; set; }
    }

    [DataContract]
    public class PrintersResponse
    {
        [DataMember]
        public List<PrinterInfo10> PrinterConfigurations { get; set; }
    }



    #endregion
    
}
